package leetcode_500;

/**
 *@author 周杨
 *BattleshipsInABoard_419 
 *describe:AC 100%
 *2018年7月24日 下午2:19:37
 */
public class BattleshipsInABoard_419 {
	 public int countBattleships(char[][] board) {
	        int count = 0;
	        for (int i = 0; i < board.length; i++) {
	            for (int j = 0; j < board[i].length; j++) {
	                if (board[i][j] == 'X') {
	                    if ((j == 0 || board[i][j - 1] == '.') && 
	                        (i == 0 || board[i - 1][j] == '.')) {
	                        count++;
	                    }
	                }
	            }
	        }
	        return count;
	 }
}
